home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18529 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: ix.netcom.com!news
  2. From: Bradd W. Szonye <bradds@ix.netcom.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: RE: [HELP!] What's wrong with this code (anachronism)?
  5. Date: 20 Apr 1996 16:24:59 GMT
  6. Organization: Netcom
  7. Message-ID: <01bb2ed6.5da082e0$65c2b7c7@Zany.localhost>
  8. References: <joe.829611382@babel.ho.att.com>
  9. NNTP-Posting-Host: det-mi3-05.ix.netcom.com
  10. X-NETCOM-Date: Sat Apr 20 11:24:59 AM CDT 1996
  11. X-Newsreader: Microsoft Internet News
  12.  
  13.  
  14. On Monday, April 15, 1996, Joe Orost wrote...
  15. > "StmtDG.h", line 9: Warning (Anachronism): StmtDG::SDG_Node is not
  16. > accessible from StmtDG::SDG_Edge.
  17. > "StmtDG.h", line 9: Note: Type "CC -migration" for more on anachronisms.
  18. > "StmtDG.h", line 14: Warning (Anachronism): StmtDG::SDG_Edge is not
  19. > accessible from StmtDG::SDG_Node.
  20. > "StmtDG.h", line 32: Warning (Anachronism): StmtDG::SDG_Node is not
  21. > accessible from StmtDG_Tsort::SDG_TNode.
  22. >      1  #include "D.h"
  23. >      2
  24. >      3  class StmtDG {
  25. >      4  protected:
  26. >      5          class SDG_Node;
  27. >      6          class SDG_Edge {
  28. >      7          public:
  29. >      8                  SDG_Edge *next;
  30. >      9                  StmtDG::SDG_Node *edge;
  31. >     10          };
  32. >     11          class SDG_Node {
  33. >     12          public:
  34. >     13                  SDG_Node *next;
  35. >     14                  StmtDG::SDG_Edge *edges;
  36. >     15                  AST_INDEX node;
  37. >     16                  int indegree;
  38. >     17          };
  39. >     18          SDG_Node *first;
  40. >     19          int nodes;
  41. >     20  public:
  42. >     21          friend class StmtDG_Tsort;
  43. >     22          StmtDG();
  44. >     23          ~StmtDG();
  45. >     24          void add(AST_INDEX node);
  46. >     25          void add_edge(AST_INDEX source, AST_INDEX sink);
  47. >     26  };
  48. >     27
  49. >     28  class StmtDG_Tsort {
  50. >     29          class SDG_TNode {
  51. >     30          public:
  52. >     31                  SDG_TNode *next;
  53. >     32                  StmtDG::SDG_Node *node;
  54. >     33          };
  55. >     34          SDG_TNode *head, *cur;
  56. >     35  public:
  57. >     36          StmtDG_Tsort(StmtDG SDG);
  58. >     37          ~StmtDG_Tsort();
  59. >     38          AST_INDEX cur_stmt();
  60. >     39          void operator ++();
  61. >     40  };
  62. > Please send email.
  63. >                                 regards,
  64. >                                 joe
  65. [emailed to author:]
  66. Nested classes obey the same access rules as non-member functions.
  67. Therefore, only entities with "protected" access to StatementDG's (friends
  68. and derived classes) can access the protected nested class SDG_Node.
  69. SDG_Edge is not a friend or derived class of StatementDG, therefore it
  70. does not have access to the nested class SDG_Node. To fix this, either
  71. make SDG_Edge and SDG_Node friends of StatementDG or put their class
  72. definitions in StatementDG's "public" access section.
  73.  
  74.  
  75.